package com.xpgk.mvc.employeesServiceStatistics;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.plugin.activerecord.Record;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.codeSet.Code;
import com.xpgk.mvc.organization.Organization;
import com.xpgk.mvc.productOrgExperience.ProductOrgExperience;

public class EmployeesServiceStatisticsController extends BaseController {

	private EmployeesServiceStatisticsService employeesServiceStatisticsService = new EmployeesServiceStatisticsService();
	
	public void index(){
		setAttr("curOrgan", Organization.dao.findById(getCUserOrganIds()));
		setAttr("parts", Code.cacheGetChild(Code.fwbw_ids));
		setAttr("colspan", Code.cacheGetChild(Code.fwbw_ids).size());
		String sqlbb = "SELECT * FROM sb_product_orgexperience where organIds =? and bbExperience IS NOT NULL and dataStatus = '1'";
		String sqlkb = "SELECT * FROM sb_product_orgexperience where organIds =? and kbExperience IS NOT NULL and dataStatus = '1'";
		String sqlfr = "SELECT * FROM sb_product_orgexperience where organIds =? and frExperience IS NOT NULL and dataStatus = '1'";
		ProductOrgExperience bb = ProductOrgExperience.dao.findFirst(sqlbb,getCUserOrganIds());
		int n = 4;
		if(bb!=null){
			n++;
			setAttr("bbExp", "1");
		}else{
			setAttr("bbExp", "0");
		}
		ProductOrgExperience kb = ProductOrgExperience.dao.findFirst(sqlkb,getCUserOrganIds());
		if(kb!=null){
			n++;
			setAttr("kbExp", "1");
		}else{
			setAttr("kbExp", "0");
		}
		ProductOrgExperience fr = ProductOrgExperience.dao.findFirst(sqlfr,getCUserOrganIds());
		if(fr!=null){
			n = n+2;
			setAttr("Exp", "1");
		}else{
			setAttr("Exp", "0");
		}
		setAttr("partnum",n);
		render("employeesServiceStatistics.html");
	}
	
	/**员工服务数据查询
	 * 
	 */
	public void employeesServiceDataQuery(){
		String organIds = getPara("organIds");
		String datemin = getPara("datemin");
		String datemax = getPara("datemax");
		String range = getPara("range");
		List<Record> result = employeesServiceStatisticsService.employeesServiceDateQuery(organIds, datemin, datemax,range);
		renderJson(result);
	}
}
